package com.keywaysoft.workflow.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public class ListUtil {

    public static List<String> strToList(String str){
        return strToList(str,null);
    }

    public static List<String> strToList(String str,String join){
        if(StringUtils.isBlank(str)){
            return new ArrayList<>();
        }
        if(StringUtils.isBlank(join)){
            join = ",";
        }
        return Arrays.asList(str.split(join)).stream().map(s -> String.format(s.trim())).collect(Collectors.toList());
    }

    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.isEmpty();
    }
}
